package cj.web.admin.dao;
/*
 *  
 *  
*/
import java.util.List;
import java.util.Map;

import net.paoding.rose.jade.annotation.DAO;
import net.paoding.rose.jade.annotation.SQL;
import net.paoding.rose.jade.annotation.SQLParam;
import cj.web.admin.domain.Survey;
import cj.web.admin.domain.SurveyGroup;

/**
 * 
 * @author 
 *
 */
@DAO
public interface SurveyGroupDAO{
	
	@SQL("SELECT * FROM SurveyGroup WHERE deleteFlag=1 ")
    List<SurveyGroup> queryAll();
	
	@SQL("SELECT * FROM SurveyGroup WHERE deleteFlag=1 #if(:t.name!=''){AND name like '%##(:t.name)%' } ORDER BY updateAt DESC LIMIT :t.start,:t.length ")
    List<SurveyGroup> query(@SQLParam("t") SurveyGroup surveyGroup);
	
	@SQL("SELECT count(*) FROM SurveyGroup WHERE deleteFlag=1 #if(:t.name!=''){AND name like '%##(:t.name)%' } ")
    int querysize(@SQLParam("t") SurveyGroup surveyGroup);
    
    @SQL("SELECT * FROM SurveyGroup WHERE id=:1")
    SurveyGroup queryById(int id);
    
    @SQL("INSERT INTO SurveyGroup (name,descs,ksAt,surveyId,orderNum,deleteFlag,createUser,createAt,updateUser,updateAt) VALUES (:t.name,:t.descs,:t.ksAt,:t.surveyId,:t.orderNum,1,:t.createUser,now(),:t.updateUser,now())")
    void create(@SQLParam("t") SurveyGroup surveyGroup);
	
	@SQL("UPDATE SurveyGroup SET name=:t.name,descs=:t.descs,ksAt=:t.ksAt,surveyId=:t.surveyId,orderNum=:t.orderNum,updateUser=:t.updateUser,updateAt=now() WHERE id=:t.id")
    void updateGroup(@SQLParam("t") SurveyGroup surveyGroup);
    
    @SQL("UPDATE SurveyGroup SET deleteFlag=0 WHERE id=:1")
    void deleteById(int id);
}